<html>
<head><meta charset="utf-8"><title>Pattern matching on constants only when deriving Partial(Eq) · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html">Pattern matching on constants only when deriving Partial(Eq)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224762007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224762007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224762007">(Feb 01 2021 at 17:32)</a>:</h4>
<p>Why is it that pattern matching is only allowed on constants when the type of the constant <em>derives</em> PartialEq/Eq and not when there is a manual implementation? <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=3a00de71b7e371b86b0ce8287da1c5c2">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=3a00de71b7e371b86b0ce8287da1c5c2</a></p>



<a name="224762140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224762140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224762140">(Feb 01 2021 at 17:33)</a>:</h4>
<p>IIRC, cause a manual implementation could "lie" about equality</p>



<a name="224762188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224762188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224762188">(Feb 01 2021 at 17:34)</a>:</h4>
<p>The match logic doesn't use the actual impl, but matches directly on the structure of the object</p>



<a name="224762199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224762199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224762199">(Feb 01 2021 at 17:34)</a>:</h4>
<p>so a custom impl could disagree with match's behavior</p>



<a name="224762309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224762309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224762309">(Feb 01 2021 at 17:34)</a>:</h4>
<p><a href="https://doc.rust-lang.org/std/marker/trait.StructuralEq.html">https://doc.rust-lang.org/std/marker/trait.StructuralEq.html</a><br>
<a href="https://doc.rust-lang.org/std/marker/trait.StructuralPartialEq.html">https://doc.rust-lang.org/std/marker/trait.StructuralPartialEq.html</a></p>



<a name="224762958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224762958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224762958">(Feb 01 2021 at 17:38)</a>:</h4>
<p>Ah that's a shame. We're doing manual implementation of these traits in the <code>windows</code> crate because <a href="https://github.com/rust-lang/rust/issues/80118">they are quite slow to derive</a>.</p>



<a name="224781217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224781217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224781217">(Feb 01 2021 at 19:50)</a>:</h4>
<p>IIRC last time we checked, we saw that manually implementing the structural_match impls was still faster than using the derives (but still slower than not having them of course) ?</p>



<a name="224784454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224784454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224784454">(Feb 01 2021 at 20:16)</a>:</h4>
<p>Is deriving just the Eq also expensive? That trait has no methods</p>



<a name="224890360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224890360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224890360">(Feb 02 2021 at 15:54)</a>:</h4>
<p>No, <code>Eq</code> is fairly fast. PartialEq is much slower</p>



<a name="224891637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224891637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224891637">(Feb 02 2021 at 16:01)</a>:</h4>
<p>Do you have an example how the manual implementation looks like?</p>



<a name="224917419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224917419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224917419">(Feb 02 2021 at 18:48)</a>:</h4>
<p>When deriving both <code>eq</code> &amp; <code>ne</code> the derive compiles slightly faster than similar manual implementation. On the other hand omitting the <code>ne</code> makes quite a difference (probably we should remove it from derive unless there is some runtime impact).</p>



<a name="224918951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/224918951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#224918951">(Feb 02 2021 at 18:57)</a>:</h4>
<p>Though, the derive doesn't scale very well with the number of fields.</p>



<a name="225024181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225024181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225024181">(Feb 03 2021 at 14:41)</a>:</h4>
<p>The implementations happen in a proc macro:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span>::<span class="n">std</span>::<span class="n">cmp</span>::<span class="nb">PartialEq</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="err">#</span><span class="n">name</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">eq</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span>: <span class="kp">&amp;</span><span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="mi">0</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">other</span><span class="p">.</span><span class="mi">0</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span>::<span class="n">std</span>::<span class="n">cmp</span>::<span class="nb">Eq</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="err">#</span><span class="n">name</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="225024431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225024431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225024431">(Feb 03 2021 at 14:43)</a>:</h4>
<p>I know from benchmarking that PartialOrd is the real trouble maker when it comes to compile times. I need to benchmark whether PartialEq derivation actually impacts compile times in a noticeable way</p>



<a name="225025255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225025255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225025255">(Feb 03 2021 at 14:49)</a>:</h4>
<p>PartialEq and PartialOrd will generally produce very similar code, because they both ultimately either generate a match over the enum variants and compare the inner values or compare the struct fields.</p>



<a name="225025502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225025502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225025502">(Feb 03 2021 at 14:51)</a>:</h4>
<p>PartialOrd has a bunch more functions though, right? I think we still generate le/lt/ge/gt or more</p>



<a name="225026351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225026351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225026351">(Feb 03 2021 at 14:57)</a>:</h4>
<p>I wouldn't be surprised we do that, but I wouldn't be surprised if it just implemented <code>fn partial_cmp</code> and then let the default impls of those methods do their thing.</p>



<a name="225026572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225026572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225026572">(Feb 03 2021 at 14:59)</a>:</h4>
<p>Just checked, it exapands to implementing every method. <code>eq</code> and <code>ne</code> for <code>PartialEq</code> and 5 methods for <code>PartialOrd</code>.</p>



<a name="225026623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225026623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225026623">(Feb 03 2021 at 14:59)</a>:</h4>
<p>so off hand estimate is that <code>PartialOrd</code> is 2.5 times more expensive to derive compared to <code>PartialEq</code>.</p>



<a name="225026844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225026844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225026844">(Feb 03 2021 at 15:01)</a>:</h4>
<p>I find it interesting that <code>PartialOrd</code> derive calls the contained types' <code>partial_cmp</code> even in the <code>le</code>/<code>ge</code>/etc. methods rather than directly calling their <code>le</code>/<code>ge</code>/etc.</p>



<a name="225028041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225028041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225028041">(Feb 03 2021 at 15:08)</a>:</h4>
<p>That seems like something that should be fixed - partial_cmp can do more work than le/ge/etc in some cases</p>



<a name="225030359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225030359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225030359">(Feb 03 2021 at 15:22)</a>:</h4>
<p>With regards to PartialOrd, my intention is to remove all remaining operators as described in <a href="https://github.com/rust-lang/rust/pull/81384#issuecomment-772446462">https://github.com/rust-lang/rust/pull/81384#issuecomment-772446462</a>.</p>



<a name="225030415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225030415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225030415">(Feb 03 2021 at 15:22)</a>:</h4>
<p>The implementation additionally uses nested closures which triggers an exponential compile time behaviour with respect to the number of fields.</p>



<a name="225033676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225033676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225033676">(Feb 03 2021 at 15:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="243558">Steven Fackler</span> <a href="#narrow/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq)/near/225028041">said</a>:</p>
<blockquote>
<p>That seems like something that should be fixed - partial_cmp can do more work than le/ge/etc in some cases</p>
</blockquote>
<p>Yeah, that would make sense to me, but also an observable change in user code that would need to be scrutinized.</p>



<a name="225033986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225033986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225033986">(Feb 03 2021 at 15:48)</a>:</h4>
<p>Why observable change? They both use <code>partial_cmp</code> if not for the fact they are currently derived incorrectly <a href="https://github.com/rust-lang/rust/issues/81373">#81373</a>, the behaviour would be exactly the same.</p>



<a name="225034469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225034469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225034469">(Feb 03 2021 at 15:50)</a>:</h4>
<p>And if you are not currently encountering the buggy part of the implementation, the fields would observe exactly the same sequence of <code>partial_cmp</code> invocations.</p>



<a name="225035421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225035421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225035421">(Feb 03 2021 at 15:56)</a>:</h4>
<p>Oh, I misunderstood, you were proposing using <code>le</code>/<code>ge</code> directly. This would require at least two calls per field to deal with incomparable values. Old implementation used to work like that, but that in turn was exponential in runtime with respect to type nesting.</p>



<a name="225035555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225035555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225035555">(Feb 03 2021 at 15:57)</a>:</h4>
<p>I think, only last trailing comparison could be implemented like that.</p>



<a name="225036275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225036275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225036275">(Feb 03 2021 at 16:01)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/50011">https://github.com/rust-lang/rust/pull/50011</a></p>



<a name="225036520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225036520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225036520">(Feb 03 2021 at 16:02)</a>:</h4>
<p>ah right</p>



<a name="225053556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225053556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225053556">(Feb 03 2021 at 17:54)</a>:</h4>
<p>Do we do the "if you're deriving both PartialOrd and Ord then use the Ord implementation from PartialOrd" thing?  (Like IIRC with do with Copy+Clone)</p>



<a name="225061363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225061363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225061363">(Feb 03 2021 at 18:44)</a>:</h4>
<p>We don't do anything fancy like that for Ord.</p>



<a name="225062788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Pattern%20matching%20on%20constants%20only%20when%20deriving%20Partial%28Eq%29/near/225062788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Pattern.20matching.20on.20constants.20only.20when.20deriving.20Partial(Eq).html#225062788">(Feb 03 2021 at 18:52)</a>:</h4>
<p>Just thinking that <code>Ord</code> would be the one where potentially-overridden <code>PartialOrd::lt</code> in subfields becomes not a concern, so might save some volume-of-code-emitted.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>